﻿// SMIL is a community project avaipublic lable under the Microsoft Public License (Ms-PL)
// Code is provided as is and with no warrenty – Use at your own risk
// View the project and the latest code at http://smil.codeplex.com/

var getTagFromTitle = function (tagName, title) {
    var tags = document.getElementsByTagName(tagName);
    for (var i = 1; i < tags.length; i++) {
        var tempString = tags[i].id;
        if (tags[i].id.indexOf(title) > 1) {
            return tempString;
        }
    }
    return 'null';
};

var getTextFieldByItsPrefix = function (refTag, refTagId) {
    var prefix = refTag.substr(0, refTag.indexOf(refTagId, 0)) + "TextField";
    return prefix;
};

var WriteGeomToSharePoint = function (geom) {
    var labelTag = getTagFromTitle("span", "lCoordinate");
    var nCoord = getTextFieldByItsPrefix(labelTag, "lCoordinate");
    document.getElementById(nCoord).value = geom; //"n=" + n + " e=" + e + " zoom=" + zoom;
};

var setInitParams = function () {
    var labelTag2 = getTagFromTitle("span", "lCoordinate");
    var nCoord = getTextFieldByItsPrefix(labelTag2, "lCoordinate");
    var mapVal = document.getElementById(nCoord).value;
    document.getElementById("initParameters").value = "n=20,e=20,zoom=10";    //mapVal;
};

var getInputParam = function (tag, id) {
    var lSMILTag = getTagFromTitle(tag, id);
    if (lSMILTag == "null")
        return;
    return document.getElementById(lSMILTag).value;
};

var getUrl = function () {
    return document.URL;
};

var getStyledGeometries = function (id) {
    var element = document.getElementById(id);
    return element.value;
};